package router

import (
	"github.com/gin-gonic/gin"
	"kuangstudy-mall/apis/order-web/api"
	middlewares "kuangstudy-mall/apis/order-web/middleawares"
)

func InitOrderRouter(RouterGroup *gin.RouterGroup) {
	shopcartRouter := RouterGroup.Group("/shopcart").Use(middlewares.JWTAuth())
	{
		shopcartRouter.POST("/list", (&api.ShopcartApi{}).FindCartListByUserId)
		shopcartRouter.POST("/save", (&api.ShopcartApi{}).AddGoodsToShoppingCart)
		shopcartRouter.POST("/update", (&api.ShopcartApi{}).UpdateShoppingCartStatus)
		shopcartRouter.POST("/del", (&api.ShopcartApi{}).DeleteShoppingCartItems)
	}

	orderRouter := RouterGroup.Group("/order").Use(middlewares.JWTAuth())
	{
		orderRouter.POST("/list", (&api.OrderApi{}).FindCartListByUserId)
		orderRouter.POST("/create", (&api.OrderApi{}).CreateGoodsOrder)
		orderRouter.POST("/update", (&api.OrderApi{}).UpdateGoodsOrderStatus)
		orderRouter.POST("/detail", (&api.OrderApi{}).FindGoodsOrderDetail)
	}

	wxpayRouter := RouterGroup.Group("/wxpay")
	{
		wxpayRouter.POST("/small/openid", (&api.WeixinJSPayApi{}).GendWxAuthAPI)
		wxpayRouter.POST("/small/prepay", (&api.WeixinJSPayApi{}).WeixinPay_JSAPI_SMALL)
		wxpayRouter.POST("/small/query", (&api.WeixinJSPayApi{}).WeixinPay_QueryOrderByOutTradeNo)
		wxpayRouter.POST("/small/callback", (&api.WeixinJSPayApi{}).WeixinPay_JSAPI_CALLBACK)
	}
}
